package br.com.clubelivro.modelo;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;

import br.com.gaspar.utils.entidade.EntidadeBase;

@Entity
@NamedQueries({
	@NamedQuery(name="Funcionario.buscarTodos", query="select obj from Funcionario obj order by obj.nome"),
	@NamedQuery(name="Funcionario.naoDeveExistirNome", query="select count(obj.id) from Funcionario obj where obj.nome = :p0")
})
public class Funcionario extends EntidadeBase {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(name="func_seq", sequenceName="func_sequence", allocationSize=1)
	@GeneratedValue(strategy=GenerationType.AUTO, generator="func_seq")
	private Long id;
	
	private String nome;

	@Override
	public void setId(Long id) {
		this.id = id;
	}

	@Override
	public Long getId() {
		return this.id;
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Funcionario other = (Funcionario) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
	
	

}
